	
       <div class="modal fade in ip-box ztree-fa" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" id="permissionAssignment">
			<div class="modal-dialog modal-lg" role="document" >
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
						<h4 class="modal-title" id="myModalLabel">角色功能授权页面</h4>
					</div>
					<div class="modal-body">
				                	
				                <button id="ztreeExpandAll">全部展开</button>	<button id="ztreeUnExpandAll">全部收缩</button>
				                
				                <a href="javascrip:void(0)" id="checkAll">全选</a>
				                
                                <a href="javascrip:void(0)" id="unCheckAll">反选</a>
				               	
				               	<div id="ztreeList">
							         
							    	<ul id="tree" class="ztree" style="width:1024px; overflow:auto;"></ul> 
							    
							    </div> 
							    
							   
							     
							    <input type="hidden" id=functionData name="functionData" value="{{res}}" >
							    
							    <form id="form1">
							     
							    	<input type="hidden" id=selectedData name="selectedData" value="{{selectedData}}" >
							    
							    	<input type="hidden" id= roleId name="roleId" value="{{roleID}}">
							                              
	                                <div class="modal-footer">
	                               
					                    <button type="button" id="myButton" class="btn btn-primary" >保存</button></div>
	            				    </div>

							   </form>
      
			        </div> 	
                  	
           		</div>
          	</div>         
		</div>

		<script>
		
		
		$(document).ready(function(){
			
			var ajaxFormOption = {
	                 type: "post",  //提交方式  
	                 dataType: "json", //数据类型  
	                 data: {"selectedData":$("#selectedData").val(),"roleId":$("#roleId").val()},//自定义数据参数，视情况添加
	                 url: "/digitalhome-boss/user/functions/ModifierRolePermissionList", //请求url  
	                 success: function (data) { //提交成功的回调函数  
	                	 $("#permissionAssignment").modal("hide");
	                 }
	             };

	             //不需要submit按钮，可以是任何元素的click事件
	             $("#myButton").click(function () {
	                 $("#form1").ajaxSubmit(ajaxFormOption);
	                 return false;
	             });
	             
	             
	             //$.fn.zTree.getZTreeObj("tree").expandAll(true);
			
		});
		
		
		
		
			$("#checkAll").click(function(){
				
				$("ul input").each(function(){
					
					$(this).attr("checked","");
					
					
					$("#selectedData").val($("#functionData").val());
					
				});
			});



			$("#unCheckAll").click(function(){
				
				$("ul input").each(function(){
					
					$(this).removeAttr("checked");
					
					$("#selectedData").val("[]");
					
				});
			});
		
		
		
		$("#ztreeExpandAll").click(function () {
			
	　　                  $.fn.zTree.getZTreeObj("tree").expandAll(true);
	　　    
	　　      });
		
		
		$("#ztreeUnExpandAll").click(function () {
			
		　　     $.fn.zTree.getZTreeObj("tree").expandAll(false);
		
		});
		
		Array.prototype.indexOf = function(val) {
			
			for (var i = 0; i < this.length; i++) {
				
			if (this[i] == val) return i;
			
			}
			return -1;
		};
			
		Array.prototype.remove = function(val) {
			
			var index = this.indexOf(val);
			
			if (index > -1) {
				
			this.splice(index, 1);
			
			}
			
		};
		
		
		
		function fnIsChecked(obj){
			
		 //debugger;
			//判断是否有check属性
			var temp;
			
			if(obj.attributes.checked){
				
				 temp = obj.attributes.checked.value;
				
			}else{
				
				 temp="";
				
			}
			//取得当前input  value属性值
			var values = obj.attributes.value.value;
			
			var tempData = values.split(":");
			
			var functionPermissID = tempData[0]+":"+tempData[1];

			var myselectedData = $("#selectedData").val();

			var myData = JSON.parse(myselectedData);

			var selectedData = [];

			for(var i=0;i<myData.length;i++){

					selectedData.push(myData[i]);
			}
			
			
			selectedData = _.uniq(selectedData);
			
			
			if( temp == "checked" ) {
				
				obj.removeAttribute('checked');

				selectedData.remove(functionPermissID);

				$("#selectedData").val(JSON.stringify(selectedData));
	
			}
			else {
				
				obj.setAttribute('checked', 'checked');

				selectedData.push(functionPermissID);

				$("#selectedData").val(JSON.stringify(selectedData));

			}
		}		
		</script>